package com.example.controller.redistemplate;

import com.example.annotation.PassToken;
import com.example.utils.redistemplate.RedisTemplateUtils;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ChenXiaoBin
 * on 2020-03-15
 */
@RestController
@RequestMapping("/v1.0/template")
public class RedisTemplateController {
    @Autowired
    private RedisTemplateUtils redisTemplateUtils;

    @PutMapping(value = "redis/list")
    @ApiOperation(value = "消息队列", notes = "消息队列")
    @PassToken
    public void redisList() {
        while (true) {
            redisTemplateUtils.leftPush("redisList", "1");
            try {
                Thread.sleep(100000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
